import cv2
import numpy as np 
import os
image = cv2.imread(r'E:\python\church01.jpg')
#image = cv2.imread(r'E:\python\church02.jpg')
#image = cv2.imread(r'E:\python\church03.jpg')
if image is None:
    print("path     wrong")
    try:
        os._exit(0)
    except:
        print('Program is dead.')
print("image ok")
#获取FAST角点探测器
fast = cv2.FastFeatureDetector_create(threshold=40, \
nonmaxSuppression=True, type=cv2.FAST_FEATURE_DETECTOR_TYPE_9_16)
kp = fast.detect(image, None) 
cv2.drawKeypoints(image, kp, image, color = (255, 255, 255))
print ("Threshold: ", fast.getThreshold())#输出阈值
print ("nonmaxSuppression: ", fast.getNonmaxSuppression())#是否使用非极大值抑制
print ("Total Keypoints with nonmaxSuppression: ", len(kp))#特征点个数
cv2.imshow('result',image)
cv2.waitKey(0)
cv2.destroyAllWindows()